import 'dart:async';
import 'package:geolocator/geolocator.dart';

class DnpLocationTool {
  // 强制获取新位置，忽略缓存
  static Future<Position> getFreshLocation() async {
    return await Geolocator.getCurrentPosition(
      forceAndroidLocationManager: true,
      locationSettings: LocationSettings(
        accuracy: LocationAccuracy.best,
        timeLimit: Duration(seconds: 15),
      ),
    );
  }

  static Future<bool> checkLocationPermission() async {
    LocationPermission permission = await Geolocator.checkPermission();
    if (permission == LocationPermission.denied) {
      permission = await Geolocator.requestPermission();
    }
    return permission == LocationPermission.always ||
        permission == LocationPermission.whileInUse;
  }
}